package com.rainyun.rcmc.own.bukkit.biz;

import com.rainyun.rc.command.annotation.BeanCmdBiz;
import com.rainyun.rc.command.annotation.CmdLine;
import com.rainyun.rc.config.NodeConfig;
import com.rainyun.rc.ioc.Beanzy;
import com.rainyun.rcmc.bukkit.RainBukkitUtil;
import com.rainyun.rcmc.bukkit.annotation.Buk;
import com.rainyun.rcmc.own.common.BeanRc;
import com.rainyun.rcmc.own.common.RcGlobal;
import com.rainyun.rcmc.own.config.RcCmdAttr;
import com.rainyun.rcmc.own.config.RcLang;
import org.bukkit.command.CommandSender;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;

@Buk
@BeanCmdBiz("raincore")
public class BizRC{

	@Beanzy
	BizCommon bizCommon;
	@Beanzy
	RcGlobal global;
	@BeanRc(BeanRc.BeansRc.NodeConf)
	NodeConfig<?> ncf;

	@CmdLine("nmscomp <file...>")
	@RcCmdAttr(order = 10,
			help = "&a /rc nmscomp <文件名...>" +
					"\n&7 对插件文件进行NMS兼容处理",
			check = "nmscomp",
			tab = "nmscomp"
	)
	public void nmsComp(CommandSender sd,File ...file) {
		RainBukkitUtil.NmsBukCompatify(new ArrayList<>(Arrays.asList(file)));
		bizCommon.sendWithPrefix(sd,"操作成功~");
	}

	@CmdLine("reload")
	@RcCmdAttr(order = 20,async = true,
			help = "§a /rc reload" +
					"\n&7 重载插件"
	)
	public void reload(CommandSender sd) {
		if(global.BukReload())
			bizCommon.sendWithPrefix(sd, ncf.get(RcLang.reload_success));
		else
			bizCommon.sendWithPrefix(sd, ncf.get(RcLang.reload_error));
	}

}









